package eteam.aps.systeminterface.service;

import eteam.aps.common.R;
import eteam.aps.common.exceptions.AuthException;
import eteam.aps.systeminterface.model.dto.OrgDto;
import eteam.aps.systeminterface.model.entity.OrgEntity;
import eteam.aps.systeminterface.model.reqparam.IdParam;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Update;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * 机构服务
 */
public interface IOrgController {
    /**
     * 获取机构树[全机构树]
     *
     * @return
     */
    @GetMapping(value = "/api/org/getorgtree")
    R<List<OrgEntity>> getOrgTree() throws Exception, AuthException;

    /**
     * 根据机构ID获取下级机构列表
     *
     * @param orgId: 机构Id
     * @return
     */
    @GetMapping(value = "/api/org/getorglist")
    R<List<OrgEntity>> getOrgList(@RequestParam String orgId) throws Exception, AuthException;

    /**
     * 搜索机构列表
     *
     * @param keyword: 检索关键字
     * @return
     */
    @GetMapping(value = "/api/org/searchorglist")
    R<List<OrgEntity>> searchOrgList(@RequestParam String keyword) throws Exception, AuthException;

    /**
     * 新增机构
     *
     * @param orgDto: 机构信息
     * @return
     */
    @PostMapping(value = "/api/org/createorg")
    R<OrgEntity> createOrg(@Validated(Insert.class) @RequestBody OrgDto orgDto) throws Exception, AuthException;

    /**
     * 更新机构
     *
     * @param orgDto: 机构信息
     * @return
     */
    @PostMapping(value = "/api/org/updateorg")
    R<OrgEntity> updateOrg(@Validated(Update.class) @RequestBody OrgDto orgDto) throws Exception, AuthException;

    /**
     * 删除机构
     *
     * @param orgParam: 机构Id参数
     * @return
     */
    @PostMapping(value = "/api/org/deleteorg")
    R deleteOrg(@Validated @RequestBody IdParam orgParam) throws Exception, AuthException;
}
